import java.awt.image.BufferedImage;

public abstract class TotalObject {
    public static final int LIVE = 0;
    public static final int DEAD = 1;
    public static final int REMOVE = 2;
    public static final int UP = 0;
    public static final int RIGHT = 1;
    public static final int DOWN = 2;
    public static final int LEFT = 3;
    public static final int nearattack = 0;
    public static final int farattack = 1;
    boolean isenter;
    protected int state = LIVE;
    int x;
    int y;
    int width;
    int height;
    int riseheight;//腾空高度
    int life;
    int movedirection;//移动方向
    boolean isdroping;
    boolean ismoving;
    int speed;

    public TotalObject(int x, int y, int width, int height, int life,int speed) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.life = life;
        this.speed = speed;
    }

    //相碰
    public boolean isHit(TotalObject totalObject) {
        int x1 = this.x-totalObject.width;
        int x2 = this.x+this.width;
        int y1 = this.y-totalObject.height;
        int y2 = this.y+this.height;
        int x = totalObject.x;
        int y = totalObject.y;

        return x>=x1 && x<=x2
                &&
                y>=y1 && y<=y2;
    }

    public void goDead() {
        state = DEAD;
        life = 0;
    }

    public void drop() {
        if (!isenter)return;
        if (riseheight<=0){
            isdroping = false;//停止下落
        }
        else {
            y+=3;
            riseheight-=3;
        }

    }

    public abstract void reducelife();
    //得到图片
    public abstract BufferedImage getImage();
    public void letstop(){
        ismoving = false;
    }



    public boolean isdead(){
        return life<=0;
    }

    public  boolean isLand() {
        return riseheight <=0;
    }
}
